*new matchin (in wide)
egen maxpts = rowmax(pts*)


*Hug_all_v2 includes 2013, use but keep just Hug_ for robustness check
*matching*
gen highGRI = 0
replace highGRI = 1 if gri > 4.4
gen repressive = 0
replace repressive = 1 if pts > 2
cem logpop loggdp polity2 , treatment(repressive)
foreach X of varlist cem* {
rename `X' first_`X'
}
cem  loggdp polity2 , treatment(repressive)
foreach X of varlist cem* {
rename `X' second_`X'
}
cem loggdp logpop polity2 numIGOs civilwar, treatment(repressive)
foreach X of varlist cem* {
rename `X' third_`X'
}

cem avgpop avggdp avgwar avgIGO avgpolity, treatment(repressive)
foreach X of varlist cem* {
rename `X' fourth_`X'
}

egen avgpop = rowmean(logpop*)
egen avggdp = rowmean(loggdp*)
egen avgwar = rowmean(civilwar*)
egen avgIGO = rowmean(numIGOs*)
egen avgpolity = rowmean(polity2*)


gen Hug_all_v2 = Hug_all
replace Hug_all_v2 = sponsor_use if year == 2013

*models*
xtreg gri L.Hug_all_v2 L.pts L.logpop L.loggdp L.majMuslim if allMember == 1, mle
outreg2 using "main.doc", word dec(2) label replace
xtreg gri L.Hug_all_v2 L.pts L.logpop L.loggdp L.majMuslim if allMember == 1 & third_cem_matched == 1, mle
outreg2 using "main.doc", word dec(2) label append

xtreg gri L.Hug_lesstenall L.pts L.logpop L.loggdp L.majMuslim if allMember == 1 , mle
outreg2 using "main.doc", word dec(2) label append
xtreg gri L.Hug_lesstenall L.pts L.logpop L.loggdp L.majMuslim if allMember == 1 & third_cem_matched == 1, mle
outreg2 using "main.doc", word dec(2) label append

*robustness**
xtreg gri L.Hug_all_v2 L.polity2 L.logpop L.loggdp L.majMuslim if allMember == 1, mle
outreg2 using "polity.doc", word dec(2) label replace
xtreg gri L.Hug_all_v2 L.polity2 L.logpop L.loggdp L.majMuslim if allMember == 1 & third_cem_matched == 1, mle
outreg2 using "polity.doc", word dec(2) label append

xtreg gri L.Hug_all_v2 L.pts L.lji L.logpop L.loggdp L.majMuslim if allMember == 1, mle
outreg2 using "lji.doc", word dec(2) label replace
xtreg gri L.Hug_all_v2 L.lji L.pts L.logpop L.loggdp L.majMuslim if allMember == 1 & third_cem_matched == 1, mle
outreg2 using "lji.doc", word dec(2) label append

xtreg gri L.Hug_all L.pts L.logpop L.loggdp L.majMuslim if allMember == 1, mle
outreg2 using "womine.doc", word dec(2) label replace
xtreg gri L.Hug_all L.pts L.logpop L.loggdp L.majMuslim if allMember == 1 & third_cem_matched == 1, mle
outreg2 using "womine.doc", word dec(2) label append

xtreg gri L.Hug_sponsor L.pts L.logpop L.loggdp L.majMuslim if allMember == 1, mle
outreg2 using "justsponsor.doc", word dec(2) label replace
xtreg gri L.Hug_sponsor L.pts L.logpop L.loggdp L.majMuslim if allMember == 1 & third_cem_matched == 1, mle
outreg2 using "justsponsor.doc", word dec(2) label append

xtreg gri L.Hug_all_v2 L.pts L.logpop L.loggdp L.majMuslim L.Ethnic if allMember == 1, mle
outreg2 using "Ethnic.doc", word dec(2) label replace
xtreg gri L.Hug_all_v2 L.pts L.logpop L.loggdp L.majMuslim L.Ethnic if allMember == 1 & third_cem_matched == 1, mle
outreg2 using "Ethnic.doc", word dec(2) label append

xtreg gri L.Hug_all_v2 L.pts L.logpop L.loggdp L.majMuslim L.Religion if allMember == 1, mle
outreg2 using "Religion.doc", word dec(2) label replace
xtreg gri L.Hug_all_v2 L.pts L.logpop L.loggdp L.majMuslim L.Religion if allMember == 1 & third_cem_matched == 1, mle
outreg2 using "Religion.doc", word dec(2) label append

xtreg gri L.Hug_all_v2 L.pts L.logpop L.loggdp L.majMuslim if allMember == 1, fe
outreg2 using "fe.doc", word dec(2) label replace
xtreg gri L.Hug_all_v2 L.pts L.logpop L.loggdp L.majMuslim if allMember == 1 & third_cem_matched ==1, fe
outreg2 using "fe.doc", word dec(2) label append

xtgee gri L.Hug_all L.pts L.logpop L.loggdp L.majMuslim if allMember == 1, family(gaussian) link(identity) corr(exc)
outreg2 using "gee.doc", word dec(2) label replace
xtgee gri L.Hug_all L.pts L.logpop L.loggdp L.majMuslim if allMember == 1 & third_cem_matched == 1, family(gaussian) link(identity) corr(exc)
outreg2 using "gee.doc", word dec(2) label append

reg gri L.Hug_all_v2 L.pts L.logpop L.loggdp L.majMuslim i.ccode if allMember == 1 [iweight = third_cem_weights]
outreg2 using "ols.doc", word dec(2) label replace


xtmixed gri L.Hug_all L.pts L.logpop L.loggdp  || ccode: L.majMuslim if allMember == 1, cov(uns) mle
outreg2 using "xtmixed.doc", word dec(2) label replace
xtmixed gri L.Hug_all L.pts L.logpop L.loggdp  || ccode: L.majMuslim if allMember == 1 & third_cem_matched == 1, cov(uns) mle
outreg2 using "xtmixed.doc", word dec(2) label append

xtreg gri L.Hug_all_v2 if allMember == 1 & third_cem_matched == 1, mle
outreg2 using "nocontrols.doc", word dec(2) label replace

reg NX Hug_all_v2 pts logpop loggdp majMuslim if allMember == 1, cluster(year)
outreg2 using "RAS.doc", word dec(2) label replace
reg MX Hug_all_v2 pts logpop loggdp majMuslim if allMember == 1
outreg2 using "RAS.doc", word dec(2) label append
reg SCX Hug_all_v2 pts logpop loggdp majMuslim if allMember == 1
outreg2 using "RAS.doc", word dec(2) label append

xtreg gri L.Hug_all_v2 L.pts if allMember == 1, mle
outreg2 using "multico.doc", word dec(2) label replace
xtreg gri L.Hug_all_v2 L.majMuslim if allMember == 1, mle
outreg2 using "multico.doc", word dec(2) label append
xtreg gri L.Hug_all_v2 L.loggdp if allMember == 1, mle
outreg2 using "multico.doc", word dec(2) label append
xtreg gri L.Hug_all_v2 L.logpop if allMember == 1, mle
outreg2 using "multico.doc", word dec(2) label append

xtreg gri L.Hug_all_v2 L.pts if allMember == 1 & third_cem_matched == 1, mle
outreg2 using "multico2.doc", word dec(2) label replace
xtreg gri L.Hug_all_v2 L.majMuslim if allMember == 1 & third_cem_matched == 1, mle
outreg2 using "multico2.doc", word dec(2) label append
xtreg gri L.Hug_all_v2 L.loggdp if allMember == 1 & third_cem_matched == 1, mle
outreg2 using "multico2.doc", word dec(2) label append
xtreg gri L.Hug_all_v2 L.logpop if allMember == 1 & third_cem_matched == 1, mle
outreg2 using "multico2.doc", word dec(2) label append

xtreg gri L.Hug_all_v2 L.pts L.logpop L.loggdp L.majMuslim if allMember == 1 & first_cem_matched == 1, mle
outreg2 using "altmatching.doc", word dec(2) label replace
xtreg gri L.Hug_all_v2 L.pts L.logpop L.loggdp L.majMuslim if allMember == 1 & second_cem_matched == 1, mle
outreg2 using "altmatching.doc", word dec(2) label append
xtreg gri L.Hug_all_v2 L.pts L.logpop L.loggdp L.majMuslim if allMember == 1 & fourth_cem_matched == 1, mle
outreg2 using "altmatching.doc", word dec(2) label append

xtreg gri L.Hug_all_v2 L.pts L.logpop L.loggdp L.majMuslim Obama if allMember == 1, mle
outreg2 using "Obama.doc", word dec(2) label replace
xtreg gri L.Hug_all_v2 L.pts L.logpop L.loggdp L.majMuslim Obama if allMember == 1 & third_cem_matched == 1, mle
outreg2 using "Obama.doc", word dec(2) label append

xtreg gri L.Hug_all_v2 L.pts L.logpop L.loggdp L.majMuslim UNSC if allMember == 1, mle
outreg2 using "UNSC.doc", word dec(2) label replace
xtreg gri L.Hug_all_v2 L.pts L.logpop L.loggdp L.majMuslim UNSC if allMember == 1 & third_cem_matched == 1, mle
outreg2 using "UNSC.doc", word dec(2) label append

*without xt*
reg gri L.Hug_all_v2 L.pts L.logpop L.loggdp L.majMuslim if allMember == 1
outreg2 using "noxt.doc", word dec(2) label replace
reg gri L.Hug_all_v2 L.pts L.logpop L.loggdp L.majMuslim if allMember == 1 [iweight = third_cem_weights]
outreg2 using "noxt.doc", word dec(2) label append

*tests and figures*

xtreg gri L.Hug_all_v2 L.pts L.logpop L.loggdp L.majMuslim if allMember == 1, fe
estimates store fixed
xtreg gri L.Hug_all_v2 L.pts L.logpop L.loggdp L.majMuslim if allMember == 1, re
estimates store random
hausman fixed random, sigmamore

xtreg gri L.Hug_all_v2 L.pts L.logpop L.loggdp L.majMuslim if allMember == 1 & third_cem_matched == 1 , mle
margins, at(L.Hug_all_v2 = (0 12 24 33) L.majMuslim = 1 L.pts = 5)
marginsplot, ylabel(2.4 (0.5) 6.6) ytitle("Increase in religious repression") xtitle("Number of HRC resolutions")

sum gri Hug_all_v2 pts logpop loggdp majMuslim if allMember == 1
hist gri
hist Hug_all_v2

drop cem*
imb logpop loggdp polity2 , treatment(repressive)
cem logpop loggdp polity2 , treatment(repressive)

reg gri L.Hug_all_v2 L.pts L.logpop L.loggdp L.majMuslim i.ccode if allMember == 1
vif








